//
//  WOContactSection.m
//  WOPrototype
//
//  Created by Olof Millberg on 2010-04-27.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "WOContactSection.h"


@implementation WOContactSection
@synthesize contactList, editable;

- (id) initWithTitle:(NSString*)aTitle contactList:(NSMutableArray*)list editable:(BOOL)isEditable
{
	if (self = [super init])
	{
		self.title = aTitle;
		self.contactList = list;
		self.editable = isEditable;
	}
	return self;
}

+ (id) contactSectionWithTitle:(NSString *)aTitle contactList:(NSMutableArray *)list editable:(BOOL)isEditable
{
	WOContactSection *section = [[[WOContactSection alloc] initWithTitle:aTitle 
															 contactList:list 
																editable:isEditable] autorelease];
	return section;
}

- (NSInteger) numberOfRows
{
	if (editable)
		return [contactList count] + 1;
	else
		return [contactList count];
}

- (NSString *) identifierAtRow:(NSInteger)row
{
	if (row < [contactList count])
		return @"ContactCell";
	else
		return @"AddContactCell";
}

- (CGFloat) heightForRow:(NSInteger)row
{
	return 44;
}

- (void) dealloc
{
	[contactList release];
	[super dealloc];
}

@end
